package io.renren.modules.backstage.controller;


import io.renren.common.exception.Result;
import io.renren.modules.backstage.entity.ProductEntity;
import io.renren.common.exception.StatusCode;
import io.renren.modules.backstage.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 贷款产品表
 *
 * @author syh
 * @email sunlightcs@gmail.com
 * @date 2022-05-18 10:38:05
 */
@RestController
@RequestMapping("/product")
@CrossOrigin
public class ProductController {
    @Autowired
    private ProductService productService;

    @Resource
    private StringRedisTemplate srt;

    @RequestMapping("/list")
    public Result getProductList(@RequestBody ProductEntity productEntity){
        Result result= productService.getAll(productEntity);
        srt.opsForValue().set("username","lsw141");
        return result;
    }
    @RequestMapping("/getByPid")
    public Result getByProductId(@RequestParam("productId") Integer productId){
     ProductEntity productEntity=  productService.getByProductId(productId);
     return  new Result(StatusCode.OK,"查询成功",true,productEntity);
    }

}
